*WHAT'S ACROSS THE BORDER?
*JHA, NEUMARK, AND RODRIGUEZ-LOPEZ

*CONSTRUCTS CZONE-STATE-20INDUSTRY DATASET

include directories_build.do

* Load data at the czone-state-industry level
use "`cbpdir'`s'cbp_czone_state_1990_2016", clear


drop if year==.

* SIC87XX: 20 industries

merge m:1 sic87dd using "`cbpdir'`s'cbp_sic87dd_sic87ss_sic87xx_desc.dta"
keep if _merge==3
drop _merge 
drop if year==.

compress

collapse (sum) emp est qp1 ap  (first)  state_min state_max multi count three sic87xx_desc, by(czone sic87xx state year)

merge m:1 year czone state using "`popdir'`s'czone_state_pop_1990_2018.dta"
keep if _merge==3
drop _merge 
drop if year==.

merge m:1 czone using "`czonedir'`s'cw_czone_region_AADHP.dta"
keep if _merge==3
drop _merge 
drop if year==.

save "`cbpdir'`s'cbp_czone_state_wages_20ind_1990_2016.dta", replace
